// config:{
//     level:[
//         { name: 'tablet', value: 768 },
//         { name: 'desktop', value: 1024 },
//         { name: 'hignDesktop', value: 1560 }
//     ]
// }

function ScreenPick(config) {
    this.config = config
}

ScreenPick.prototype.run = function (jElement, callback, noFindCallback) {
    var width = $(window).width()
    if (this.config == null && this.config.level.length == 0) {
        console.log('检查ScreenPick config')
        return
    }
    var allowList = []
    this.config.level.forEach(function (l, index) {
        if (width > l.value) {
            allowList.push(l)
        }
    })
    for (var i = allowList.length - 1; i >= 0; i--) {
        var value = $(jElement).attr('s-' + allowList[ i ].name)
        if (undefined == value) {
            continue
        }
        callback(value.split(':'))
        return
    }
    noFindCallback()

}
